package org.sgx.gwteditors.testgallery.manual.test;

import java.util.Map;

import org.sgx.gwteditors.client.impl1.basetypes.Color;
import org.sgx.gwteditors.client.impl1.simple.ColorEditor;
import org.sgx.gwteditors.client.util.TestUtil;
import org.sgx.gwteditors.testgallery.gallery.Test;
import org.sgx.gwteditors.testgallery.gallery.TestResources;

import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.resources.client.ExternalTextResource;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.Panel;

public class ColorEditorTest1 implements Test {	

@Override
public void test(Panel parent) {	
	Color c = new Color("ededed");
	final ColorEditor ed = new ColorEditor(); 
	ed.load(c); 
	parent.add(new Label("Please choose a color to proceed: ")); 
	parent.add(ed.getWidget());
	
	//now add a Button, when clicked it will print the Color edited by the user:
	parent.add(new Button("Get Edited Color", new ClickHandler() {			
		@Override
		public void onClick(ClickEvent event) {
			Window.alert("User choose color: "+ed.flush());
		}
	})); 	
}
	
	//test stuff
	@Override
	public String getName() {
		return "ColorEditorTest1";
	}

	@Override
	public String[] getTags() {		
		return null;
	}

	@Override
	public String getDescription() {
		return "a small example on using Color editor. ";
	}
	@Override
	public Map<String, ExternalTextResource> getJavaSources() {
		return TestUtil.getResource(getName(), TestResources.INSTANCE.SimpleColorEditorTest());
	}
	
}
